	<title>权限菜单版本设置</title>
	<style>	
	</style>
	<link rel="stylesheet" type="text/css" href="__STATIC__/js/layui256/layui/css/layui.css">
</head>
<body>
	<div class="layui-tab">
		<ul class="layui-tab-title">
			<?php $currentTab = 2;?>
			<include file="rbac_menu/public/nav">
		</ul>
		<div class="layui-col-md12">
			<table class="layui-table">
			<colgroup>
				<col width="60">
				<col>
				<col>
				<col>
				<col>
				<col width="200">
			</colgroup>
				<thead>
					<tr>
						<th>序号</th>
						<th>名称</th>
						<th>创建时间</th>
						<th>备注</th>
						<th>价格</th>
						<th>操作&nbsp;&nbsp;<button type="button" class="layui-btn layui-btn-xs layui-btn-radius" onclick="addVersion();">添加</button></th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="vo">
					<tr>
						<td>{++$key}</td>
						<td>{$vo.name}</td>
						<td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
						<td>{$vo.remark}</td>
						<td>{$vo.price}</td>
						<td>
							<button type="button" class="layui-btn layui-btn-xs layui-btn-radius" onclick="setBaseMenu({$vo.id});">菜单设置</button>
							<button type="button"  class="layui-btn layui-btn-xs layui-btn-radius layui-btn-normal" onclick="addVersion({$vo.id});">修改</button>
							<button  type="button"  href="{:url('authorization/RbacMenuVersion/delete')}?id={$vo.id}" data-msg="确定要删除此版本吗?" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger zy-ajax-confirm">删除</button>
						</td>
					</tr>
					</volist>
				</tbody>
			</table>
			<empty name="list">
				暂无数据~
			</empty>
		</div>
	</div>
<script src="__STATIC__/js/jquery.js"></script>
<script src="__STATIC__/js/layui256/layui/layui.all.js"></script>
<script src="__STATIC__/js/layer/layer.js"></script>
<script src="__STATIC__/js/custom/custom.js"></script>
<script type="text/javascript">
	var addVersion = function( id = '' ){
		layer.open({
			offset:'100px;',
			type: 2,
			title:'权限菜单版本设置',
			area: ['700px', '450px'],
			fixed: false, //不固定
			maxmin: true,
			btn:['提交','取消'],
			content: '{:url("authorization/RbacMenuVersion/add")}'+((id=='')?"":"?id="+id+"&edit=edit"),
			yes:function( index , layero ){
				var res = $(layero).find("iframe")[0].contentWindow.callback();
				if( id != '' ){
					res ['id'] = id;
					res ['edit'] = 'edit';
				}
				$.post( '{:url("authorization/RbacMenuVersion/add")}', res , function( data ){
					//data = JSON.parse( data );
					let icon = ( data.code == 200 )? 1 : 5;
					layer.msg( data.message , { time:1500, icon:icon } ,function(){
						if(icon ==1 ) window.location.reload(); 
					} );
				} , 'json' );
			}
		});
	}

	var setBaseMenu = function( versionId ){
		var layerNum = layer.open({
			type: 2,
			title:'版本菜单设置',
			area: ['700px', '80%'],
			fixed: false, //不固定
			maxmin: true,
			btn:['保存','取消'],
			content: '{:url("authorization/RbacMenuVersion/setBaseMenu")}?versionId='+versionId,
			yes:function( index , layero ){
				var res = $(layero).find("iframe")[0].contentWindow.getChecked();
				$.post( '{:url("authorization/RbacMenuVersion/baseMenuPost")}', {list:res,versionId:versionId} , function( data ){
					//data = JSON.parse( data );
					let icon = ( data.code == 200 )? 1 : 5;
					layer.msg( data.message , { time:1500, icon:icon } , function (){
						if( icon == 1 ) layer.close(layerNum);
					});
				} , 'json' );
			}
		});
	}
</script>
</body>
</html>